﻿using Genius.Brain.Shared.BO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Genius.Brain.Shared.Locator;
using Genius.Brain.Shared.Strategy;

namespace Genius.Brain.Impl.Strategy
{
    class TokenDatabaseRecordJsonConverterStrategy : IJsonConverterStrategy<ITokenDatabaseRecord>
    {
        public ITokenDatabaseRecord ConvertFromJson(JToken rec)
        {
            var d = BrainLocator.GetTokenDatabaseRecord();
            d.Token = rec["token"].Value<string>();
            d.Language = rec["language"].Value<string>();
            d.Pattern = new List<string>();
            foreach (var p in rec["pattern"])
                d.Pattern.Add(p.Value<string>());
            return d;
        }
    }
}
